const {
  Tool,
  Event,
  Storage,
  API,
  throttle
} = global.$util
const regeneratorRuntime = require('../../libs/asyncRuntime/runtime')
const app = getApp()

Page({
  data: {
      userInfo: {},
      tools: [{
          icon: 'add-square',
          text: '入库订单',
          status: 1,
          dotType: 'nonPay'
      },
          {
              icon: 'card',
              text: '出库订单',
              status: 2,
              dotType: 'nonDelivery'
          },
      ],
      secondTools: [
          {
              icon: 'shop-o',
              text: '店铺',
              page: '/pages/mine/shop/shop',
          },
          {
              icon: 'phone-o',
              text: '手机号',
              page: '/pages/mine/phone/phone',
          },
          {
            icon: 'location-o',
            text: '地址管理',
            page: '/pages/address/address',
        },
      ],
  },
  onLoad: function (options) {
      this.getUserInfo()
  },
  onUnload: function () {
  },
  onShow() {
    this.getTabBar().init();
  },

  // 获取用户账户信息
  getUserInfo() {
    let callBack = (datas) => {
      this.setData({
          userInfo: datas.user
      })
    }
    app.getUserInfo(callBack)
  },
  
  itemClicked: throttle(function (e) {
      let page = '/pages/mine/order/order?myOrderModuleSource=1'
      let item = e.currentTarget.dataset.item
      if (item) {
          page += '&query=' + item.status
      }
      Tool.navigateTo(page)
  }),

  toolClicked(e) {
      let page = e.currentTarget.dataset.page
      Tool.navigateTo(page)
  },
})
